<template>
  <div class="SensorSettings" >
    <div ref="SensorSettings">
    <div class="top">
      <div class="border"></div>
      <h3>
        {{SensorSettings.setting}}
        <span>{{roomNo}}</span>
        <span>{{SensorSettings.roomTitle}}</span>
      </h3>
    </div>
    <div class="main" ref="main">
      <!-- 厕所异常设定 -->
      <el-form
        :model="settingList"
        status-icon
        :rules="rules"
        ref="settingList"
        label-position="top"
        class="demo-settingList"
      >
        <div>
          <h3>{{SensorSettings.toilet}}</h3>
          <div style="display:flex">
            <el-form-item :label="SensorSettings.foucsTime" prop="toiletAttentionTime"  ref="fouscTime">
              <el-input :disabled="!isEditor" v-model.trim="settingList.toiletAttentionTime" @change="changeFoucsTime">
                <template slot="append">{{SensorSettings.minute}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.toiletAttentionTime}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.warningTime" prop="toiletWarningTime" ref="warningTime">
              <el-input :disabled="!isEditor" v-model.trim="settingList.toiletWarningTime"  @change="changeWarningTime">
                <template slot="append">{{SensorSettings.minute}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.toiletWarningTime}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.unusualTime" prop="toiletUnusualTime"  ref="unusualTime">
              <el-input :disabled="!isEditor" v-model.trim="settingList.toiletUnusualTime"  @change="changeUnusualTime">
                <template slot="append">{{SensorSettings.minute}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.toiletUnusualTime}}</h5>
            </el-form-item>
          </div>
        </div>

        <!-- 室温异常设定 -->
        <div>
          <h3>{{SensorSettings.temperature}}</h3>
          <div style="display:flex">
            <el-form-item :label="SensorSettings.usualtemp" prop="temperatureMinimum" ref="tempBottom">
              <el-input :disabled="!isEditor" v-model.trim="settingList.temperatureMinimum" @change="changeTempBottom">
                <template slot="append">℃&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.temperatureMinimum}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.unusualtemp" prop="temperatureMaximum" ref="tempTop">
              <el-input :disabled="!isEditor" v-model.trim="settingList.temperatureMaximum" @change="changeTempTop"> 
                <template slot="append">℃</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.temperatureMaximum}}</h5>
            </el-form-item>
          </div>
          <!-- <el-form-item :label="SensorSettings.checkTime" prop="temperatureMeasuringTimeInterval" style="margin-top:8px">
            <el-input :disabled="!isEditor" style="width:26%" v-model.trim="settingList.temperatureMeasuringTimeInterval">
              <template slot="append">{{SensorSettings.second}}</template>
            </el-input>
            <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.temperatureMeasuringTimeInterval}}</h5>
          </el-form-item> -->
        </div>

        <!-- 呼吸异常 -->

        <div >
          <h3>{{SensorSettings.breath}}</h3>
          <div style="display:flex">
            <el-form-item :label="SensorSettings.bottom" prop="breathMinTimes"  ref="breathBottom">
              <el-input :disabled="!isEditor" v-model.trim="settingList.breathMinTimes" @change="changeBreathBottom">
                <template slot="append">{{SensorSettings.times}}/{{SensorSettings.minute}}  ~</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.breathMinTimes}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.top" prop="breathMaxTimes"  ref="breathTop">
              <el-input :disabled="!isEditor" v-model.trim="settingList.breathMaxTimes" @change="changeBreathTop">
                <template slot="append">{{SensorSettings.times}}/{{SensorSettings.minute}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.breathMaxTimes}}</h5>
            </el-form-item>
          </div>
        </div>

        <!-- 心跳 -->
        <div>
          <h3>{{SensorSettings.heartbeat}}</h3>
          <div style="display:flex">
            <el-form-item :label="SensorSettings.bottom" prop="heartbeatMinimum" ref="heartbeatBottom">
              <el-input :disabled="!isEditor" v-model.trim="settingList.heartbeatMinimum" @change="changeHeartbeatBottom">
                <template slot="append">{{SensorSettings.times}}/{{SensorSettings.minute}}  ~</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.heartbeatMinimum}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.top" prop="heartbeatMaximum" ref="heartbeatTop">
              <el-input :disabled="!isEditor" v-model.trim="settingList.heartbeatMaximum" @change="changeHeartbeatTop">
                <template slot="append">{{SensorSettings.times}}/{{SensorSettings.minute}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.heartbeatMaximum}}</h5>
            </el-form-item>
          </div>
        </div>

        <!-- 身体异常 -->
        <div style="display:none">
          <h3>{{SensorSettings.body}}</h3>
          <el-form-item :label="SensorSettings.checkTime" prop="vitalMeasuringTimeInterval">
            <el-input :disabled="!isEditor" style="width:25%" v-model.trim="settingList.vitalMeasuringTimeInterval">
              <template slot="append">{{SensorSettings.minute}}</template>
            </el-input>
            <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.vitalMeasuringTimeInterval}}</h5>
          </el-form-item>
        </div>

        <!-- 离床异常 -->
        <div>
          <h3>{{SensorSettings.leaveBed}}</h3>
          <el-form-item :label="SensorSettings.checkTime" prop="leaveBedMeasuringTimeInterval">
            <el-input :disabled="!isEditor" style="width:58%" v-model.trim="settingList.leaveBedMeasuringTimeInterval">
              <template slot="append">
                <div style="display:flex">
                  <p style="margin-left:20px;color:black">{{SensorSettings.second}}</p>
                  <span style="margin-left:10px;color:#ff0000">
                    <p style="margin-left:20px;color:#ff0000">{{SensorSettings.warningWord}}</p>
                    <p style="line-height: 0;margin-left:20px;color:#ff0000">{{SensorSettings.warningWord2}}</p>
                  </span>
                </div>
              </template>
            </el-input>
            <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.leaveBedMeasuringTimeInterval}}</h5>
          </el-form-item>
        </div>

         <!-- 离床检测时间 -->
          <el-row class="facilitySensorSet-b-form" v-if="false">
          <h3>離床後のカメラの監視時間</h3>
            <el-form-item label="監視時間設定値" prop="cameraBedTime">
              <el-input :disabled="!isEditor" style="width:25%" v-model.trim="settingList.cameraBedTime" @input="changeCameraBedTime">
                <template slot="append">
                  {{SensorSettings.second}}
                </template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.cameraBedTime}}</h5>
            </el-form-item>
        </el-row>

        <!-- 离床开关 -->
          <el-row class="facilitySensorSet-b-form">
          <h3>離床アラート音</h3>
          <el-col :span="12">
            <el-form-item>
                <el-row class="switch">
                  <el-switch
                    v-model="settingList.leaveBedSound"
                    :disabled="!isEditor || settingList.leaveBedMeasuringTimeInterval == 0"
                    active-text="オン（鳴る）"
                    inactive-text="オフ（鳴らない）">
                  </el-switch>
                </el-row>
              </el-form-item>
          </el-col>
        </el-row>

        <!-- 徘徊异常 -->
        <!-- <div>
          <h3>{{SensorSettings.backOn}}</h3>
          <div style="display:flex">
            <el-form-item :label="SensorSettings.timeStart" prop="walkMeasuringStartTime">
               <el-time-picker
                  :disabled="!isEditor"
                  v-model="settingList.walkMeasuringStartTime"
                  format='HH:mm'
                  value-format='HH:mm'
                   style="width:82%">
                </el-time-picker>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.walkMeasuringStartTime}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.timeEnd" prop="walkMeasuringEndTime">
               <el-time-picker
                  :disabled="!isEditor"
                  v-model="settingList.walkMeasuringEndTime"
                  format='HH:mm'
                  value-format='HH:mm'
                  style="width:82%">
                </el-time-picker>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.walkMeasuringEndTime}}</h5>
            </el-form-item>
          </div>
          <el-form-item :label="SensorSettings.checkTime" prop="walkMeasuringTimeInterval">
            <el-input :disabled="!isEditor" style="width:58%" v-model.trim="settingList.walkMeasuringTimeInterval">
              <template slot="append">
                {{SensorSettings.second}}
                <span
                  style="margin-left:20px;color:#ff0000"
                >{{SensorSettings.backgWord}}</span>
              </template>
            </el-input>
            <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.walkMeasuringTimeInterval}}</h5>
          </el-form-item>
        </div> -->

        <!-- 摔倒异常 -->
        <!-- <div>
          <h3>{{SensorSettings.fall}}</h3>
          <el-form-item :label="SensorSettings.checkFallTime" prop="tumbleMeasuringFrame">
            <el-input :disabled="!isEditor" style="width:58%" v-model.trim="settingList.tumbleMeasuringFrame">
              <template slot="append">
                {{SensorSettings.hui}}
                <span
                  style="margin-left:20px;color:#ff0000"
                >{{SensorSettings.warningFall}}</span>
              </template>
            </el-input>
            <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.tumbleMeasuringFrame}}</h5>
          </el-form-item>

           <el-form-item :label="SensorSettings.cameraCheckTime" prop="cameraCheckTime">
            <el-input :disabled="!isEditor" style="width:26%" v-model.trim="settingList.cameraCheckTime">
              <template slot="append">
                {{SensorSettings.second}}
              </template>
            </el-input>
            <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.cameraCheckTime}}</h5>
          </el-form-item>
        </div> -->

        <!-- 报警录像 -->
         <div>
          <h3>{{SensorSettings.policeVideo}}</h3>
           <div style="display:flex">
            <el-form-item :label="SensorSettings.beforeTime" prop="beforeDuration" >
              <el-input :disabled="!isEditor" v-model.trim="settingList.beforeDuration" >
                <template slot="append">{{SensorSettings.second}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.beforeDuration}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.afterTime" prop="afterDuration"  >
              <el-input :disabled="!isEditor" v-model.trim="settingList.afterDuration">
                <template slot="append">{{SensorSettings.second}}</template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.afterDuration}}</h5>
            </el-form-item>
          </div>
        </div>

        <!-- fillDuration -->
          <el-row class="facilitySensorSet-b-form" v-if="false">
          <h3>転倒アラート間隔時間</h3>
            <el-form-item label="アラート間隔時間設定値" prop="fillDuration">
              <el-input :disabled="!isEditor" style="width:25%" v-model.trim="settingList.fillDuration">
                <template slot="append">
                  {{SensorSettings.second}}
                </template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.fillDuration}}</h5>
            </el-form-item>
        </el-row>

         <!-- 夜间巡视时间段 -->
       <div>
          <h3>{{SensorSettings.PatrolTime}}</h3>
          <div style="display:flex">
            <el-form-item :label="SensorSettings.nightStartTime" prop="leaveRoomAlertStartTime">
               <el-time-picker
                  :disabled="!isEditor"
                  :editable="false"
                  :clearable="false"
                  v-model="settingList.leaveRoomAlertStartTime"
                  format='HH:mm:ss'
                  value-format='HH:mm:ss'
                   style="width:82%">
                </el-time-picker>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.leaveRoomAlertStartTime}}</h5>
            </el-form-item>
            <el-form-item :label="SensorSettings.nightEndTime" prop="leaveRoomAlertEndTime">
               <el-time-picker
                  :disabled="!isEditor"
                  :editable="false"
                  :clearable="false"
                  v-model="settingList.leaveRoomAlertEndTime"
                  format='HH:mm:ss'
                  value-format='HH:mm:ss'
                  style="width:37%">
                </el-time-picker>
                <span
                  style="color:#ff0000"
                >{{SensorSettings.nightWord}}</span>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.leaveRoomAlertEndTime}}</h5>
            </el-form-item>
          </div>
        </div>

        <!-- 夜間徘徊アラート間隔時間 -->
          <el-row class="facilitySensorSet-b-form" v-if="false">
          <h3>夜間巡回異常アラートの間隔時間</h3>
            <el-form-item label="アラート間隔発報の設定値" prop="leaveDuration">
              <el-input :disabled="!isEditor" style="width:25%" v-model.trim="settingList.leaveDuration">
                <template slot="append">
                  {{SensorSettings.second}}
                </template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.leaveDuration}}</h5>
            </el-form-item>
        </el-row>

        <!-- 夜間徘徊アラート遅延時間 -->
          <el-row class="facilitySensorSet-b-form">
          <h3>夜間巡回異常アラートの遅延時間</h3>
            <el-form-item label="アラート遅延発報の設定値" prop="leaveRoomDuration">
              <el-input :disabled="!isEditor" style="width:25%" v-model.trim="settingList.leaveRoomDuration">
                <template slot="append">
                  {{SensorSettings.second}}
                </template>
              </el-input>
              <h5>{{SensorSettings.settingTime}}&nbsp;&nbsp;{{DefaultSetting.leaveRoomDuration}}</h5>
            </el-form-item>
        </el-row>


      </el-form>

      <h3>※入力がない場合は初期設定(施設設定)が有効となります</h3>
    </div>
    </div>
     <div class="bottom">
        <el-button type="info" :size="size" @click="cancel">{{SensorSettings.cancel}}</el-button>
        <el-button  v-if="!isEditor" style="margin-left:100px" type="primary" :size="size" @click="print">{{SensorSettings.print}}</el-button>
        <el-button v-if="!isEditor" style="margin-left:100px" type="warning" :size="size" @click="editor">{{SensorSettings.editor}}</el-button>
        <el-button v-if="isEditor" style="margin-left:100px" type="danger" :size="size" @click="enter">{{SensorSettings.enter}}</el-button>
        <el-button type="danger" v-if="isEditor" style="margin-left:100px" :size="size" @click="initial">{{
          SensorSettings.initial
        }}</el-button>
      </div>
  </div>
</template>
<script>
import bus from "../../../vuex/eventBus"; //引入eventBus,接收子界面传递的跳转指令,然后在父界面跳转,添加tab
export default {
  data() {
    return {
      SensorSettings: this.$t("m.SensorSettings"), //引入 lang 里面的字符串资源,
       size:"medium ",
       roomNo:'',
       isEditor:false,
      settingList: {
        // id: 0,
        toiletAttentionTime: "",
        toiletWarningTime: "",
        toiletUnusualTime: "",
        temperatureMaximum: "",
        temperatureMinimum: "",
        temperatureMeasuringTimeInterval: "",
        breathMaxTimes: "",
        breathMinTimes: "",
        heartbeatMinimum: "",
        heartbeatMaximum: "",
        vitalMeasuringTimeInterval: "",
        leaveBedMeasuringTimeInterval: "",
        walkMeasuringStartTime: "",
        walkMeasuringEndTime: "",
        walkMeasuringTimeInterval: "",
        tumbleMeasuringFrame: "",
        cameraCheckTime:'',
        leaveRoomAlertStartTime:"", //夜间巡视开始时间
        leaveRoomAlertEndTime:"", //夜间巡视结束时间
        beforeDuration:'',
        afterDuration:"",
        leaveBedSound:false, //new by fzq
        cameraBedTime:'',
        fillDuration:'',
        leaveDuration:'',
        leaveRoomDuration:'', //new by fzq end at 2021.0525

      },
      DefaultSetting:{}, //施设默认值
      acceptLanguage:'ja_JP',//数据请求传参需要传的语言  ja_JP----日文

    };
  },
  methods: {
     /* 
      清除校验
    */
    clearValidate(formName) {//formName为传入要清除的prop ，可以是整个form表单，也可以是一个
      this.$refs[formName].clearValidate();
    },
    changeCameraBedTime(val){
      if(val == 0){
        this.settingList.leaveBedSound = false;
      }
    },
    /* 
      注意时间清除警告时间和异常时间的错误提示
    */
    changeFoucsTime(){
      if(Number(this.settingList.toiletAttentionTime)<Number(this.settingList.toiletWarningTime) && Number(this.settingList.toiletWarningTime)<Number(this.settingList.toiletUnusualTime)){
       //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
       this.clearValidate('warningTime')
       this.clearValidate('unusualTime')
       //2.分开判断  警告时间  和异常时间
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.toiletWarningTime))==true && this.settingList.toiletWarningTime.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   if(this.settingList.toiletWarningTime.length>=1 && this.settingList.toiletWarningTime.length<=4){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.toiletWarningTime) === 'number' && !isNaN(this.settingList.toiletWarningTime)){
        //       //2.1.4不能小于100
        //       if(this.settingList.toiletWarningTime>=100){
        //         this.clearValidate('warningTime')
        //       }
        //     }
        //   }
          
        // }
        // //2.2.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.toiletUnusualTime))==true && this.settingList.toiletUnusualTime.indexOf(".")==-1){
        //   //2.2.2判断菜长度
        //   if(this.settingList.toiletUnusualTime.length>=1 && this.settingList.toiletUnusualTime.length<=4){
        //     //2.2.3判断是否为数字类型
        //     if(typeof Number(this.settingList.toiletUnusualTime) === 'number' && !isNaN(this.settingList.toiletUnusualTime)){
        //       //2.1.4不能小于100
        //       if(this.settingList.toiletUnusualTime>=100){
        //         this.clearValidate('unusualTime')
        //       }
        //     }
        //   }
        // }
      }
    },
    
    /* 
      警告时间清除注意时间和异常时间的错误提示
    */
    changeWarningTime(){
       if(Number(this.settingList.toiletAttentionTime)<Number(this.settingList.toiletWarningTime) && Number(this.settingList.toiletWarningTime)<Number(this.settingList.toiletUnusualTime)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('fouscTime')
        this.clearValidate('unusualTime')
        //2.分开判断  注意时间  和异常时间
        //2.1.1判断不能有小数点
        // console.log("jin  111")
        // if(Number.isInteger(Number(this.settingList.toiletAttentionTime))==true && this.settingList.toiletAttentionTime.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   console.log("jin  222")
        //   if(this.settingList.toiletAttentionTime.length>=1 && this.settingList.toiletAttentionTime.length<=4){
        //     console.log("jin 333")
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.toiletAttentionTime) === 'number' && !isNaN(this.settingList.toiletAttentionTime)){
        //       console.log("jin 444")
        //       //2.1.4不能小于100
        //       if(this.settingList.toiletAttentionTime>=100){
        //         this.clearValidate('fouscTime')
        //       }
        //     }
        //   }
          
        // }
        // //2.2.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.toiletUnusualTime))==true && this.settingList.toiletUnusualTime.indexOf(".")==-1){
        //   //2.2.2判断菜长度
        //   if(this.settingList.toiletUnusualTime.length>=1 && this.settingList.toiletUnusualTime.length<=4){
        //     //2.2.3判断是否为数字类型
        //     if(typeof Number(this.settingList.toiletUnusualTime) === 'number' && !isNaN(this.settingList.toiletUnusualTime)){
        //       //2.1.4不能小于100
        //       if(this.settingList.toiletUnusualTime>=100){
        //         this.clearValidate('unusualTime')
        //       }
        //     }
        //   }
        // }
      }
    },

    /* 
      异常时间清除注意时间和警告时间的错误提示
    */
    changeUnusualTime(){
       //1.先判断三者的大小
      console.log(Number(this.settingList.toiletAttentionTime)<Number(this.settingList.toiletWarningTime),Number(this.settingList.toiletWarningTime)<Number(this.settingList.toiletUnusualTime))
      if(Number(this.settingList.toiletAttentionTime)<Number(this.settingList.toiletWarningTime) && Number(this.settingList.toiletWarningTime)<Number(this.settingList.toiletUnusualTime)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('fouscTime')
        this.clearValidate('warningTime')
        //2.分开判断  注意时间  和警告时间
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.toiletAttentionTime))==true && this.settingList.toiletAttentionTime.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   if(this.settingList.toiletAttentionTime.length>=1 && this.settingList.toiletAttentionTime.length<=4){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.toiletAttentionTime) === 'number' && !isNaN(this.settingList.toiletUnusualTime)){
        //       //2.1.4不能小于100
        //       if(this.settingList.toiletAttentionTime>=100){
        //         this.clearValidate('fouscTime')
        //       }
        //     }
        //   }
          
        // }
        // //2.2.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.toiletWarningTime))==true && this.settingList.toiletWarningTime.indexOf(".")==-1){
        //   //2.2.2判断菜长度
        //   if(this.settingList.toiletWarningTime.length>=1 && this.settingList.toiletWarningTime.length<=4){
        //     //2.2.3判断是否为数字类型
        //     if(typeof Number(this.settingList.toiletWarningTime) === 'number' && !isNaN(this.settingList.toiletWarningTime)){
        //       //2.1.4不能小于100
        //       if(this.settingList.toiletWarningTime>=100){
        //         this.clearValidate('warningTime')
        //       }
        //     }
        //   }
        // }
      }
    },

    /* 
      温度下限清除温度上限的错误提示语  
    */
    changeTempBottom(){
       if(Number(this.settingList.temperatureMinimum)<=Number(this.settingList.temperatureMaximum)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('tempTop')
        //2.分开判断 温度上限
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.temperatureMaximum))==true && this.settingList.temperatureMaximum.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   console.log(this.settingList.temperatureMaximum.length)
        //   if(this.settingList.temperatureMaximum.length>=1 && this.settingList.temperatureMaximum.length<=3){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.temperatureMaximum) === 'number' && !isNaN(this.settingList.temperatureMaximum)){
        //       //2.1.4不能为空
        //       if(this.settingList.temperatureMaximum!=''){
        //         this.clearValidate('tempTop')
        //       }
        //     }
        //   }
          
        // }
      }
    },

    /* 
    温度上限清除温度下限的错误提示物
   */
    changeTempTop(){
        if(Number(this.settingList.temperatureMinimum)<=Number(this.settingList.temperatureMaximum)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('tempBottom')
        //2.分开判断 温度下限
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.temperatureMinimum))==true && this.settingList.temperatureMinimum.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   console.log(this.settingList.temperatureMinimum.length)
        //   if(this.settingList.temperatureMinimum.length>=1 && this.settingList.temperatureMinimum.length<=3){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.temperatureMinimum) === 'number' && !isNaN(this.settingList.temperatureMinimum)){
        //       //2.1.4不能为空
        //       if(this.settingList.temperatureMinimum!=''){
        //         this.clearValidate('tempBottom')
        //       }
        //     }
        //   }
          
        // }
      }
    },

    /* 
      呼吸下限清除呼吸上限的错误提示语
    */
    changeBreathBottom(){
       if(Number(this.settingList.breathMinTimes)<=Number(this.settingList.breathMaxTimes)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('breathTop')
        //2.分开判断 呼吸上限
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.breathMaxTimes))==true && this.settingList.breathMaxTimes.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   if(this.settingList.breathMaxTimes.length>=1 && this.settingList.breathMaxTimes.length<=3){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.breathMaxTimes) === 'number' && !isNaN(this.settingList.breathMaxTimes)){
        //       //2.1.4不能为空
        //       if(this.settingList.breathMaxTimes!=''){
        //         if(this.settingList.breathMaxTimes>0){
        //           this.clearValidate('breathTop')
        //         }
        //       }
        //     }
        //   }
          
        // }
      }
    },

    /* 
      呼吸上限清除呼吸下限的错误提示语
    */
    changeBreathTop(){
      if(Number(this.settingList.breathMinTimes)<=Number(this.settingList.breathMaxTimes)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('breathBottom')
        //2.分开判断 呼吸下限
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.breathMinTimes))==true && this.settingList.breathMinTimes.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   if(this.settingList.breathMinTimes.length>=1 && this.settingList.breathMinTimes.length<=3){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.breathMinTimes) === 'number' && !isNaN(this.settingList.breathMinTimes)){
        //       //2.1.4不能为空
        //       if(this.settingList.breathMinTimes!=''){
        //         if(this.settingList.breathMinTimes>0){
        //           this.clearValidate('breathBottom')
        //         }
        //       }
        //     }
        //   }
          
        // }
      }
    },

    /* 
      心跳下限清除心跳上限的错误提示语
    */
    changeHeartbeatBottom(){
      if(Number(this.settingList.heartbeatMinimum)<Number(this.settingList.heartbeatMaximum)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('heartbeatTop')
        //2.分开判断 心跳上限
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.heartbeatMaximum))==true && this.settingList.heartbeatMaximum.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   if(this.settingList.heartbeatMaximum.length>=1 && this.settingList.heartbeatMaximum.length<=3){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.heartbeatMaximum) === 'number' && !isNaN(this.settingList.heartbeatMaximum)){
        //       //2.1.4不能为空
        //       if(this.settingList.heartbeatMaximum!=''){
        //         if(this.settingList.heartbeatMaximum>0){
        //           this.clearValidate('heartbeatTop')
        //         }
        //       }
        //     }
        //   }
          
        // }
      }
    },

    /* 
      心跳上限清除心跳下限的错误提示语
    */
    changeHeartbeatTop(){
       if(Number(this.settingList.heartbeatMinimum)<Number(this.settingList.heartbeatMaximum)){
        //by guo 2020-3-28-15:19修改  测试又要求改成这样  只需要判断大小满足就去掉提示语
        this.clearValidate('heartbeatBottom')
        //2.分开判断 心跳下限
        //2.1.1判断不能有小数点
        // if(Number.isInteger(Number(this.settingList.heartbeatMinimum))==true && this.settingList.heartbeatMinimum.indexOf(".")==-1){
        //   //2.1.2判断菜长度
        //   if(this.settingList.heartbeatMinimum.length>=1 && this.settingList.heartbeatMinimum.length<=3){
        //     //2.1.3判断是否为数字类型
        //     if(typeof Number(this.settingList.heartbeatMinimum) === 'number' && !isNaN(this.settingList.heartbeatMinimum)){
        //       //2.1.4不能为空
        //       if(this.settingList.heartbeatMinimum!=''){
        //        if(this.settingList.heartbeatMinimum>0){
        //           this.clearValidate('heartbeatBottom')
        //         }
        //       }
        //     }
        //   }
          
        // }
      }
    },

    cancel() {
      bus.$emit("homePage", {
        type: "remove",
        path: "/SensorSettings",
        showpath: "/habitableroomDetail"
      });
    },

     //打印
    print(){
      this.$print(this.$refs.SensorSettings);
    },

    //编辑按钮
    editor(){
      this.isEditor =true;
    },
        //初始化居室设置
    initial() {
      if (sessionStorage.getItem("roomId")) {
        console.log(sessionStorage.getItem("roomId"));
        this.$get(
          "dmc/defaultLifeTransducerConfig",
          { groupId: sessionStorage.getItem("groupId") },
          this.acceptLanguage
        ).then(res => {
          console.log(res);
          this.DefaultSetting = res;
          this.initialSensor(sessionStorage.getItem("roomId"));
        });
      }
    },

    initialSensor(roomId) {
      let params = {};
      params.roomId = roomId;
      params.toiletAttentionTime = String(
        this.DefaultSetting.toiletAttentionTime
      );
      params.toiletWarningTime = String(this.DefaultSetting.toiletWarningTime);
      params.toiletUnusualTime = String(this.DefaultSetting.toiletUnusualTime);
      params.temperatureMaximum = String(
        this.DefaultSetting.temperatureMaximum
      );
      params.temperatureMinimum = String(
        this.DefaultSetting.temperatureMinimum
      );
      params.breathMaxTimes = String(this.DefaultSetting.breathMaxTimes);
      params.breathMinTimes = String(this.DefaultSetting.breathMinTimes);
      params.heartbeatMinimum = String(this.DefaultSetting.heartbeatMinimum);
      params.heartbeatMaximum = String(this.DefaultSetting.heartbeatMaximum);
      params.vitalMeasuringTimeInterval = String(
        this.DefaultSetting.vitalMeasuringTimeInterval
      );
      params.leaveBedMeasuringTimeInterval = String(
        this.DefaultSetting.leaveBedMeasuringTimeInterval
      );
      params.walkMeasuringStartTime = String(
        this.DefaultSetting.walkMeasuringStartTime
      );
      params.walkMeasuringEndTime = String(
        this.DefaultSetting.walkMeasuringEndTime
      );
      params.walkMeasuringTimeInterval = String(
        this.DefaultSetting.walkMeasuringTimeInterval
      );
      params.cameraCheckTime = String(this.DefaultSetting.cameraCheckTime);
      params.leaveRoomAlertStartTime = String(
        this.DefaultSetting.leaveRoomAlertStartTime
      );
      //start
      params.leaveRoomAlertEndTime = String(
        this.DefaultSetting.leaveRoomAlertEndTime
      );
      params.cameraBedTime  = String(
          this.DefaultSetting.cameraBedTime
        );
      params.fillDuration  = String(
          this.DefaultSetting.fillDuration
        );
      params.leaveDuration  = String(
          this.DefaultSetting.leaveDuration
        );
      params.leaveRoomDuration  = String(
          this.DefaultSetting.leaveRoomDuration
        );
      params.leaveBedSound = this.DefaultSetting.leaveBedSound;
      params.beforeDuration = String(this.DefaultSetting.beforeDuration);
      params.afterDuration = String(this.DefaultSetting.afterDuration);
      params.temperatureMeasuringTimeInterval = "100";
      params.tumbleMeasuringFrame = "1";
      console.log(params);
      this.$put(
        "dmc/lifeTransducerConfig",
        params,
        "FORM-DATA",
        this.acceptLanguage
      ).then(res => {
        console.log(res);
        if (res.code == 200) {
          
          setTimeout(()=>{
            this.$message({ message: res.message, type: "success" });
            this.getRoomDetail()
            this.getSensorSettings(sessionStorage.getItem("roomId"));
            this.getDefaultSetting()
          },1000)
        } else {
          this.$message({ message: res.message, type: "error" });
        }
      });
    },
    
    //查询房间号
     getRoomDetail(){
        this.$get('omc/Room/lifeRoom',{roomId:sessionStorage.getItem("roomId")},this.acceptLanguage).then(res =>{
          this.roomNo = res.roomNo
        })
      },

    //查询传感器设备信息
    getSensorSettings(roomId) {
      this.$get("dmc/lifeTransducerConfig", { roomId: roomId },this.acceptLanguage).then(res => {
        //this.settingList = res;
        //this.settingList.id = String(res.id)
        this.settingList.toiletAttentionTime = String(res.toiletAttentionTime)
        this.settingList.toiletWarningTime = String(res.toiletWarningTime)
        this.settingList.toiletUnusualTime = String(res.toiletUnusualTime)
        this.settingList.temperatureMaximum = String(res.temperatureMaximum)
        this.settingList.temperatureMinimum = String(res.temperatureMinimum)
        this.settingList.temperatureMeasuringTimeInterval = String(res.temperatureMeasuringTimeInterval)
        this.settingList.breathMaxTimes = String(res.breathMaxTimes)
        this.settingList.breathMinTimes = String(res.breathMinTimes)
        this.settingList.heartbeatMinimum = String(res.heartbeatMinimum)
        this.settingList.heartbeatMaximum = String(res.heartbeatMaximum)
        this.settingList.vitalMeasuringTimeInterval = String(res.vitalMeasuringTimeInterval)
        this.settingList.leaveBedMeasuringTimeInterval = String(res.leaveBedMeasuringTimeInterval)
        //
        this.settingList.cameraBedTime  = String(
          res.cameraBedTime
        );
        this.settingList.fillDuration  = String(
          res.fillDuration
        );
        this.settingList.leaveDuration  = String(
          res.leaveDuration
        );
        this.settingList.leaveRoomDuration  = String(
          res.leaveRoomDuration
        );
        this.settingList.leaveBedSound = (res.leaveBedSound == 1);

        this.settingList.walkMeasuringStartTime = String(res.walkMeasuringStartTime)
        this.settingList.walkMeasuringEndTime = String(res.walkMeasuringEndTime)
        this.settingList.walkMeasuringTimeInterval = String(res.walkMeasuringTimeInterval)
        this.settingList.tumbleMeasuringFrame = String(res.tumbleMeasuringFrame)
        this.settingList.cameraCheckTime = String(res.cameraCheckTime)
        this.settingList.leaveRoomAlertStartTime = String(res.leaveRoomAlertStartTime)
        this.settingList.leaveRoomAlertEndTime = String(res.leaveRoomAlertEndTime)
        this.settingList.beforeDuration = String(res.beforeDuration)
        this.settingList.afterDuration = String(res.afterDuration)


      });
    },

    //查询系统默认值
    getDefaultSetting(){
      this.$get("dmc/defaultLifeTransducerConfig", { groupId:sessionStorage.getItem("groupId")},this.acceptLanguage).then(res => {
        this.DefaultSetting = res;
      });
    },

    //更新传感器设备信息
    enter() {
      this.$refs.settingList.validate(valid => {
        if (valid) {
          let params = {};
          params = this.settingList;
          params.roomId = sessionStorage.getItem("roomId")
          params.temperatureMeasuringTimeInterval="100" //手动设置100 --修改fzq 0508 11.18
          params.tumbleMeasuringFrame="1"
          params.walkMeasuringStartTime="00:00"
          params.walkMeasuringEndTime="00:00"
          params.walkMeasuringTimeInterval="23"
          params.leaveBedSound = (params.leaveBedSound?'1':'0')
          this.$put("dmc/lifeTransducerConfig", params, "FORM-DATA",this.acceptLanguage).then(
            res => {
              console.log(res);
              if (res.code == 200) {
                this.$message({ message: res.message, type: "success" });
                this.isEditor =false;
                bus.$emit("homePage", {
                  type: "remove",
                  path: "/SensorSettings",
                  showpath: "/HabitableRoomManagement"
                });
              } else {
                this.$message({ message: res.message, type: "error" });
              }
            }
          );
        } else {
          console.log("error submit!!");
          this.$message({message:this.$t("m.SensorSettings.errorMsg"),type:"error"});
          return false;
        }
      });
    }
  },
  computed: {
    rules() {
      //生命体征规则
      var minNumber = (rule, value, callback) => {
        if (value  <1) {
          callback(new Error(this.$t("m.SensorSettings.min1")));
        }
        callback();
        };
        //画面帧数规则
        var warningFallRule = (rule, value, callback) => {
          if (value  <0 || value>0&& value<5) {
            callback(new Error(this.$t("m.SensorSettings.minhua5")));
          }
          callback();
        };
        //只能为number
        var isNumber = (rule, value, callback) => {
          let newValue = Number(value)
          if (typeof newValue === 'number' && !isNaN(value)) {
          }else{
            callback(new Error(this.$t("m.SensorSettings.number")));
          }
          callback();
        };
        //在1到10之间
         var max10 = (rule, value, callback) => {
            if (value>=1 && value<=10) {
            }else{
              callback(new Error(this.$t("m.SensorSettings.max10")));
            }
            callback();
        };
        var min15 = (rule, value, callback) => {
          if (value < 15) {
            callback(new Error(this.$t("m.SensorSettings.min15")));
          }
          callback();
        };
        var max120 = (rule, value, callback) => {
          if (value > 120) {
            callback(new Error(this.$t("m.SensorSettings.max120")));
          }
          callback();
        };
        //警报前录像时长小于等于30  by guo 2020-4-14-15:33修改  小于等于120
        var max30_1=(rule, value, callback) => {
          if (value>120) {
            callback(new Error(this.$t("m.facilityManagement.max30_1")));
          }
          callback();
        };
        //警报后录像时长小于等于30
        var max30_2=(rule, value, callback) => {
          if (value>30) {
            callback(new Error(this.$t("m.facilityManagement.max30_2")));
          }
          callback();
        };
        //大于等于1
         var min100 = (rule, value, callback) => {
            if (value<1) {
              callback(new Error(this.$t("m.SensorSettings.min1_1")));
            }
            callback();
        };
      //温度下限
      var validate_TemperatureMinimum=(rule, value, callback) =>{
        console.log(this.settingList.temperatureMaximum,"==",value)
        if(this.settingList.temperatureMaximum!=""){
          if(Number(value)>Number(this.settingList.temperatureMaximum)) {
            callback(new Error(this.$t('m.facilityManagement.minTempTop')));
          }else if(Number(value)<Number(this.DefaultSetting.temperatureMinimum)){
            callback(new Error(this.$t('m.facilityManagement.minTempTop1')));
          }
        }
        callback();
      }
      //温度上限
      var validate_TemperatureMaximum=(rule, value, callback) =>{
        console.log(this.settingList.temperatureMinimum,"--")
        if(this.settingList.temperatureMinimum!=""){
          if(Number(value)<Number(this.settingList.temperatureMinimum)) {
            callback(new Error(this.$t('m.facilityManagement.minTempBottom')));
          }else if(Number(value)>Number(this.DefaultSetting.temperatureMaximum)){
            callback(new Error(this.$t('m.facilityManagement.minTempBottom1')));
          }
        }
        callback();
      }
      //呼吸下限
      var validate_BreathMinTimes=(rule, value, callback) =>{
        console.log(this.settingList.breathMaxTimes,"--")
        if(this.settingList.breathMaxTimes!=""){
          if(Number(value)>Number(this.settingList.breathMaxTimes)) {
            callback(new Error(this.$t('m.facilityManagement.minBreathTop')));
          }
        }
        callback();
      }
      //呼吸上限
      var validate_BreathMaxTimes=(rule, value, callback) =>{
        console.log(this.settingList.breathMinTimes,"==",value)
        if(this.settingList.breathMinTimes!=""){
          if(Number(value)<Number(this.settingList.breathMinTimes)) {
            callback(new Error(this.$t('m.facilityManagement.minBreathBottom')));
          }
        }
        callback();
      }
      //心跳下限
      var validate_HeartbeatMinimum=(rule, value, callback) =>{
        console.log(this.settingList.heartbeatMaximum,"--")
        if(this.settingList.heartbeatMaximum!=""){
          if(Number(value)>Number(this.settingList.heartbeatMaximum)) {
            callback(new Error(this.$t('m.facilityManagement.minHeartbeatTop')));
          }
        }
        callback();
      }
      //心跳上限
      var validate_HeartbeatMaximum=(rule, value, callback) =>{
        console.log(this.settingList.heartbeatMinimum,"==",value)
        if(this.settingList.heartbeatMinimum!=""){
          if(Number(value)<Number(this.settingList.heartbeatMinimum)) {
            callback(new Error(this.$t('m.facilityManagement.minHeartbeatBottom')));
          }
        }
        callback();
      }

      var validate_UnusualCheckTime = (rule, value ,callback) => {
        //室温监测时间间隔
        if (this.settingList.temperatureMeasuringTimeInterval <100) {
          callback(new Error(this.$t("m.facilityManagement.time100")));
        }else if(this.settingList.temperatureMeasuringTimeInterval %100!=0){
          callback(new Error(this.$t("m.facilityManagement.remainder100")));
        }
        callback();
      }
      //注意时间限制
        var  toiletAttentionTimeMin= (rule, value ,callback) => {
        if(Number(value)>=Number( this.settingList.toiletWarningTime) || Number(value)>=Number( this.settingList.toiletUnusualTime)){
          callback(new Error(this.$t("m.SensorSettings.timeLimit")));
        }
        callback();
      }
       //警告时间限制
        var  toiletWarningTimeMin= (rule, value ,callback) => {
        if(Number(value)<=Number( this.settingList.toiletAttentionTime) || Number(value)>Number( this.settingList.toiletUnusualTime)){
          callback(new Error(this.$t("m.SensorSettings.timeLimit")));
        }
        callback();
      }
       //异常时间限制
        var  toiletUnusualTimeMin= (rule, value ,callback) => {
        if(Number(value)<=Number( this.settingList.toiletAttentionTime) || Number(value)<=Number( this.settingList.toiletWarningTime)){
          callback(new Error(this.$t("m.SensorSettings.timeLimit")));
        }
        callback();
      }
      //最小为0
       var  min0= (rule, value ,callback) => {
        if(Number(value)<0){
          callback(new Error(this.$t("m.facilityManagement.min0")));
        }
        callback();
      }
      //整数的校验  
      var validate_int=(rule, value, callback) =>{
        if(Number.isInteger(Number(value))==false || value.indexOf(".")!=-1){
          callback(new Error(this.$t('m.SensorSettings.int')));
        }
        callback();
      }
      return {
        toiletAttentionTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),
            trigger: 'blur'
          },
          {
            validator: isNumber,trigger: 'blur'
          },
          {
            validator: min100,trigger: 'blur'
          },
           {
            required:true,  validator: toiletAttentionTimeMin,  trigger: 'blur'
          },
          {
            min:1,
            max:4,
            message: this.$t("m.SensorSettings.length4"),
            trigger: 'blur'
          },
          {
            validator: validate_int, trigger: 'blur'
          },
        ],
        toiletWarningTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),
            trigger: 'blur'
          },
           {
            validator: isNumber,
            trigger: 'blur'
          },
           {
            validator: min100,
            trigger: 'blur'
          },
          {
            required: true,validator: toiletWarningTimeMin, trigger: 'blur'
          },
          {
            min:1,
            max:4,
            message: this.$t("m.SensorSettings.length4"),
            trigger: 'blur'
          },
          {
            validator: validate_int, trigger: 'blur'
          },
        ],
        toiletUnusualTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
            {
            validator: isNumber,trigger: 'blur'
          },
           {
            validator: min100,trigger: 'blur'
          },
          {
            required: true,validator: toiletUnusualTimeMin, trigger: 'blur'
          },
          {
            min:1,
            max:4,
            message: this.$t("m.SensorSettings.length4"),trigger: 'blur'
          },
           {
            validator: validate_int, trigger: 'blur'
          },
        ],
        temperatureMaximum: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          { required: true,validator: validate_TemperatureMaximum, trigger: 'blur' },
          {
            validator: isNumber, trigger: 'blur'
          },
         // {validator: min0 },

          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),
             trigger: 'blur'
          },
          {
            validator: validate_int, trigger: 'blur'
          },
        ],
        temperatureMinimum: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),
             trigger: 'blur'
          },
          {required: true,validator: validate_TemperatureMinimum, trigger: 'blur'},
          //{validator: min0, trigger: "blur" },
          {
            validator: isNumber, trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),
             trigger: 'blur'
          },
           {
            validator: validate_int, trigger: 'blur'
          },
        ],
        temperatureMeasuringTimeInterval: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {
            validator: isNumber,trigger: 'blur'
          },
          {validator: min0, trigger: 'blur' },

          {
            validator: min100,trigger: 'blur'
          },
          {
            validator:validate_UnusualCheckTime,trigger: 'blur'
          },
          {
            min:3,
            max:5,
            message: this.$t("m.SensorSettings.length3_5"),trigger: 'blur'
          },
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        breathMaxTimes: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {validator: validate_BreathMaxTimes , trigger: 'blur'},
          {validator: min0 , trigger: 'blur'},

           {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        breathMinTimes: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {validator: validate_BreathMinTimes,trigger: 'blur'},
           {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0},
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        heartbeatMinimum: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {validator: validate_HeartbeatMinimum,trigger: 'blur' },
          {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0, trigger: 'blur' },
           {
            validator: validate_int,trigger: 'blur'
          },
        ],
        heartbeatMaximum: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {validator: validate_HeartbeatMaximum, trigger: 'blur' },
          {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur' },
           {
            validator: validate_int,trigger: 'blur'
          },
        ],
        vitalMeasuringTimeInterval: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {
            validator: minNumber,trigger: 'blur'
          },
           {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        leaveBedMeasuringTimeInterval: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
            {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur'},
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        fillDuration: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
            {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur'},
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        leaveDuration: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
            {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur'},
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        cameraBedTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
            {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur'},
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        leaveRoomDuration: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
            {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur'},
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        walkMeasuringStartTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {validator: min0, trigger: 'blur'},

        ],
        walkMeasuringEndTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur' },

        ],
        walkMeasuringTimeInterval: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
           {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
          {validator: min0,trigger: 'blur'},
           {
            validator: validate_int,trigger: 'blur'
          },
        ],
        tumbleMeasuringFrame: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
           {
            validator: warningFallRule,trigger: 'blur'
          },
          {
            validator: isNumber,trigger: 'blur'
          },
          {
            min:1,
            max:3,
            message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          },
           {
            validator: validate_int,trigger: 'blur'
          },
        ],
         cameraCheckTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
           {
            validator: isNumber,trigger: 'blur'
          },
          {
            validator: max10,trigger: 'blur'
          },
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        beforeDuration:[
             {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          // {validator: validate_HeartbeatMaximum, trigger: 'blur' },//by guo 2020-3-28-17:37修改 注释
          {
            validator: isNumber,trigger: 'blur'
          },
          // {
          //   min:1,
          //   max:3,
          //   message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          // },
          {
            validator: min15,
            trigger: "blur"
          },
           //by guo 2020-4-1-18:58修改  15以上 120以内
          {
            validator: max120,
            trigger: "blur"
          },
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
        afterDuration:[
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur'
          },
          // {validator: validate_HeartbeatMaximum, trigger: 'blur' },//by guo 2020-3-28-17:37修改 注释
          {
            validator: isNumber,trigger: 'blur'
          },
          // {
          //   min:1,
          //   max:3,
          //   message: this.$t("m.SensorSettings.length3"),trigger: 'blur'
          // },
           //by guo 2020-4-1-18:58修改
          {
            validator: min15,
            trigger: "blur"
          },
           //by guo 2020-4-1-18:58修改  15以上 120以内
          {
            validator: max120,
            trigger: "blur"
          },
          {
            validator: validate_int,trigger: 'blur'
          },
        ],
         //by guo 2020-3-28-17:40添加  夜间巡视开始时间和夜间巡视结束时间
        leaveRoomAlertStartTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur',
            trigger: "blur"
          },
        ],
        leaveRoomAlertEndTime: [
          {
            required: true,
            message: this.$t("m.SensorSettings.null"),trigger: 'blur',
            trigger: "blur"
          },
        ],
      };
    }
  },
  mounted() {
    this.getRoomDetail()
    this.getSensorSettings(sessionStorage.getItem("roomId"));
    this.getDefaultSetting()
  }
};
</script>
<style lang="scss" scoped>
/deep/ .el-form-item__label {
  padding: 0 0 0px !important;
  line-height: 10px !important;
  color: #0000ff !important;
}
 /deep/ input {
    width: 80%;
    margin-top: 6px !important;
    border: none !important;
    border-bottom: 2px solid #cccccc !important;
    border-radius: 1px;
    background: #f6f6f6 !important;
  }
  /deep/ .el-input-group__append {
    border: none !important;
    background: none !important;
    color: black !important;
  }
.SensorSettings {
  .top {
    display: flex;
    align-items: center;
    .border {
      width: 10px;
      height: 30px;
      background: black;
      margin-right: 10px;
    }
  }
  .main {
    margin-left: 30px;
    p {
      color: #ff0000;
      margin-top: 10px;
    }
    h5 {
      color: #999999;
      margin-top: 10px
    }
    h3 {
      margin-top: 20px;
      margin-bottom: 20px;
    }
  }
   .bottom {
      display: flex;
      justify-content: space-between;
      width: 600px;
      margin-top: 10px;
      margin-bottom: 10px;
    }
}
/deep/ .switch .el-switch__label *{
  font-size: 13px;
}



/deep/ .el-switch.is-disabled{
  opacity: 1;
}

</style>